'''
Created on 28/03/2014

@author: jpfuertes
'''
import tablature
class Translator(object):
    
    def __init__(self,from_instrument,to_instrument):
        
        self.from_instrument = from_instrument
        self.to_instrument   = to_instrument        
            
        
    def translate_position(self,position,moves):            
        note = self.from_instrument.get(position)
        notes_position = self.to_instrument.find(note)        
        return self.move(notes_position,moves)
    
    def move(self,notes_position,moves):        
        for x in notes_position:
            x.octave_offset -= moves
                                
        notes_position = sorted(notes_position,key=lambda x: x.octave_offset if x.octave_offset > 0 else x.octave_offset * -1)
        return notes_position
    
    
    
    
    
                